#!/bin/bash
set -e
CurPath="/root/quota_io_test"

function test_file_exist() {
    test_file=$1
    if [ ! -f ${test_file} ]; then
        echo "${test_file} is not exist, exit"
        exit 1
    fi
}

test_file_exist ${CurPath}/test_one.sh

for file in "write_empty_dir.sh" "write_non_empty_dir.sh" "chown_test.sh" "link_test.sh" "truncate_test.sh"
do
    test_file_exist ${CurPath}/${file}
    echo "Exec script: ${CurPath}/${file}"
    sh ${CurPath}/test_one.sh ./${file} 0
done

for file in `ls ${CurPath}/rename/ | grep -v 6_mvdir_uid_common.sh`
do
    test_file_exist ${CurPath}/rename/${file}
    echo "Exec script: ${CurPath}/rename/${file}"
    sh ${CurPath}/test_one.sh ./rename/${file} 0
done

echo "All directory quota teatcases have been tested successfully"


